package Problem05;

import java.util.ArrayList;
import java.util.Collections;

public class Doudizhu {
    public static void main(String[] args) {
        //首先定义一个集合，用来存储54张牌
        ArrayList<String>poker=new ArrayList<>();
        //定义两个数组，分别存储花色和序号
        String[]colors={"♠","♥","♦","♣"};
        String[]numbers={"2","A","K","Q","J","10","9","8","7","6","5","4","3"};
        poker.add("大王");
        poker.add("小王");
        //组装牌
        for (String number:numbers
             ) {
            for (String color : colors) {
                poker.add(color+number);
            }
        }
        //进行洗牌
        Collections.shuffle(poker);
        //进行发牌，设置四个集合，用来存储玩家和底牌
        ArrayList<String>player01=new ArrayList<>();
        ArrayList<String>player02=new ArrayList<>();
        ArrayList<String>player03=new ArrayList<>();
        ArrayList<String>Dipai=new ArrayList<>();
        for(int i=0;i<poker.size();i++){
            //遍历获取每一张牌
            String p= poker.get(i);
            //若大于等于51，则发至底牌
            if(i>=51){
                Dipai.add(p);
            }
            else if(i%3==0){
                player01.add(p);
            }
            else if(i%3==1){
                player02.add(p);
            }else if(i%3==2){
                player03.add(p);
            }

        }
        System.out.println("玩家1"+player01);
        System.out.println("玩家2"+player02);
        System.out.println("玩家3"+player03);
        System.out.println("底牌"+Dipai);
    }
}
